package com.xgimiapi.demo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import xiaofei.library.hermes.Hermes;
import xiaofei.library.hermes.HermesService;
import xiaofei.library.hermestest.IFileUtils;
import xiaofei.library.hermestest.ILoadingTask;
import xiaofei.library.hermestest.LoadingCallback;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.update_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                IFileUtils fileUtils = Hermes.getUtilityClassInService(HermesService.HermesService0.class, IFileUtils.class);
                IFileUtils fileUtils = Hermes.getUtilityClass(IFileUtils.class);
                Toast.makeText(getApplicationContext(), "" + fileUtils.getExternalCacheDir(getApplicationContext()), Toast.LENGTH_SHORT).show();
                // 测试进度.
                ILoadingTask loadingTask = Hermes.newInstance(ILoadingTask.class, "pic.png");
                loadingTask.start(new LoadingCallback() {
                    @Override
                    public void callback(int progress) {
                        Toast.makeText(getApplicationContext(), "progress:" + progress, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        });
        Hermes.init(getApplicationContext());
        Hermes.connectApp(getApplicationContext(), "xiaofei.library.hermestest");
//        Hermes.connect(getApplicationContext(), HermesService.HermesService0.class);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

}
